﻿using DFGK_WMS.IRepository;
using DFGK_WMS.Model.DTO;
using DFGK_WMS.WebAPI.Controllers.Result;
using Microsoft.AspNetCore.Mvc;

namespace DFGK_WMS.WebAPI.Controllers.物料管理
{

    [Route("api/TMaterial")]
    [ApiController]
    public class TMaterialFoundationController : ControllerBase
    {
        public ITMaterialFoundationRepository ITMaterialFoundationRepository;
        public TMaterialFoundationController(ITMaterialFoundationRepository tMaterialFoundationRepository)
        {
            ITMaterialFoundationRepository = tMaterialFoundationRepository;
        }

        [HttpPost("AddBasicMaterial")]
        public IActionResult AddBasicMaterial(FoundationMaterialDto foundationMaterialDto)
        {
            if (foundationMaterialDto == null)
            {
                return Ok(BaseResult.Result(false,"请求参数有误","500"));
            }
            var IsOk = ITMaterialFoundationRepository.AddBasicMaterial(out string msg,foundationMaterialDto);
            if(IsOk)
            {
                return Ok(BaseResult.Result(true, "添加成功", "200"));
            }
            return Ok(BaseResult.Result(true, msg, "500"));
        }
    }
}
